package com.ibeeking.found.file.api.feign.fallback;

import com.ibeeking.found.file.api.common.dto.OssPolicyDto;
import com.ibeeking.found.file.api.common.dto.OssPropDTO;
import com.ibeeking.found.file.api.feign.FileFeignBClient;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class FileFeignBFallbackFactory implements FallbackFactory<FileFeignBClient> {
    @Override
    public FileFeignBClient create(Throwable throwable) {
        return new FileFeignBClient() {
            @Override
            public ResponseResult<OssPropDTO> ossProp() {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询OSS配置失败。");
            }
            @Override
            public ResponseResult<OssPolicyDto>  policy() {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询OSS配置策略失败。");
            }
        };
    }
}
